import 'package:flutter/material.dart';
import 'package:flutter_bilibili/http/dao/login_dao.dart';
import 'package:get/get.dart';

class LoginMiddleware extends GetMiddleware {
  @override
  RouteSettings? redirect(String? route) {
    // todo:未登录进行拦截
    if (LoginDao.getBoardingPass() != null) {
      // 登录成功跳转到首页=》正常放行，不做拦截
      return null;
    }
    // 登陆失败重定向到登录页面
    return const RouteSettings(name: '/login');
  }
}
